<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>UART example</title>
<link href="tabs.css" rel="stylesheet" type="text/css" />
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="alias.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="alias.js"></script>

<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>


<script type="text/javascript">
  jQuery(document).ready(function () {
    if(gref){ // Number all _img and _table classes
      gref();
    }
  });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">nRF51 General Code Examples
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('group__uart__example__pca10001.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">UART example</div>  </div>
<div class="ingroups"><a class="el" href="group__nrf__examples__pca10001.html">PCA10001 example projects</a></div></div>
<div class="contents">

<p>Example of basic UART usage.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uart__example__pca10001.html#ga060b639e5bd6bc4aa7096412765f1756">ERROR_PIN</a>&#160;&#160;&#160;(8)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uart__example__pca10001.html#gac5774d550c2aa890fa1ad9b44cb401b9">MAX_TEST_DATA_BYTES</a>&#160;&#160;&#160;(15U)</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uart__example__pca10001.html#ga3b82dd7f24db0e0872c0c735b1a274a2">uart_quit</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static __INLINE void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uart__example__pca10001.html#ga33ac90f59ee825fec959d63ce86d9176">uart_start</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__uart__example__pca10001.html#ga840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<p>Example of basic UART usage. </p>
<p>Simple UART example that transmits and receives through the configured pins as serial device. The configure pins needs to be redirected to a COM port (for some terminal program like putty which can listen to this COM port through a terminal session) When the program start it will transmit "START: " through this serial device using <a class="el" href="group__nrf__drivers__simple__uart.html#ga76e6bde269950e02affbff121c79d408">simple_uart_putstring</a> and this should be visible on the terminal. All typed characters on this terminal will be transmitted to this program through <a class="el" href="group__nrf__drivers__simple__uart.html#gabae30008064ce450ab819949a692c511">simple_uart_get</a> and when an exit character 'q' or 'Q' is typed this program will end into an infinite loop after transmitting "EXIT!" on the new line of the terminal. </p>
<dl class="note"><dt><b>Note:</b></dt><dd>This example is not just for COM ports but can be used for any UART connection, COM port redirection is for visual verification. </dd>
<dd>
Setting the define ENABLE_LOOPBACK_TEST will assume that the TX_PIN_NUMBER is connected to RX_PIN_NUMBER and this example is used to test the loopback. In this case no com port can be used as the data flows from TX to RX and ERROR_PIN is set high for any loss of data. </dd>
<dd>
Configure your terminal application for 38400 bauds, 8 data bits and 2 stop bits. </dd></dl>
<hr/><h2>Define Documentation</h2>
<a class="anchor" id="ga060b639e5bd6bc4aa7096412765f1756"></a><!-- doxytag: member="main.c::ERROR_PIN" ref="ga060b639e5bd6bc4aa7096412765f1756" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ERROR_PIN&#160;&#160;&#160;(8)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>gpio pin number to show error if loopback is enabled </p>

<p>Definition at line <a class="el" href="pca10001_2uart__example_2main_8c_source.html#l00047">47</a> of file <a class="el" href="pca10001_2uart__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="gac5774d550c2aa890fa1ad9b44cb401b9"></a><!-- doxytag: member="main.c::MAX_TEST_DATA_BYTES" ref="gac5774d550c2aa890fa1ad9b44cb401b9" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MAX_TEST_DATA_BYTES&#160;&#160;&#160;(15U)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>max number of test bytes to be used for tx and rx </p>

<p>Definition at line <a class="el" href="pca10001_2uart__example_2main_8c_source.html#l00048">48</a> of file <a class="el" href="pca10001_2uart__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga3b82dd7f24db0e0872c0c735b1a274a2"></a><!-- doxytag: member="main.c::uart_quit" ref="ga3b82dd7f24db0e0872c0c735b1a274a2" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE void uart_quit </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sends ' Exit!' string to UART. Execution is blocked until UART peripheral detects all characters have been sent. </p>

<p>Definition at line <a class="el" href="pca10001_2uart__example_2main_8c_source.html#l00055">55</a> of file <a class="el" href="pca10001_2uart__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga33ac90f59ee825fec959d63ce86d9176"></a><!-- doxytag: member="main.c::uart_start" ref="ga33ac90f59ee825fec959d63ce86d9176" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static __INLINE void uart_start </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Sends 'Start: ' string to UART. Execution is blocked until UART peripheral detects all characters have been sent. </p>

<p>Definition at line <a class="el" href="pca10001_2uart__example_2main_8c_source.html#l00063">63</a> of file <a class="el" href="pca10001_2uart__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
<a class="anchor" id="ga840291bc02cba5474a4cb46a9b9566fe"></a><!-- doxytag: member="main.c::main" ref="ga840291bc02cba5474a4cb46a9b9566fe" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p><a class="el" href="group__gpio__example.html#ga840291bc02cba5474a4cb46a9b9566fe">main()</a> function </p>
<dl class="return"><dt><b>Returns:</b></dt><dd>0. int return type required by ANSI/ISO standard. </dd></dl>

<p>Definition at line <a class="el" href="pca10001_2uart__example_2main_8c_source.html#l00112">112</a> of file <a class="el" href="pca10001_2uart__example_2main_8c_source.html">main.c</a>.</p>

</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
      Copyright &copy 2006-2011 <a href="http://www.nordicsemi.no" style="text-decoration:none">Nordic Semiconductor</a>.
      All Rights Reserved.
      <a href="disclaimer.html">Disclaimer</a>
    </li>
   </ul>
 </div>


</body>
</html>
